<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Block</title>
</head>

<body>
<?php
include("../connection/connection.php");
include("reportFunctions.php");
$distId=$_REQUEST['distId'];
$sqlReport = "SELECT `district_id`,`district_name`,`block_id`,`block_name` FROM `tbl_lookup_location` where `district_id` = ".$distId." group by `block_id`";
$queryReport = mysql_query($sqlReport);

?>
<table border="0" width="759" cellspacing="0" cellpadding="0">
	<tr>
		<td width="800" height="26" bgcolor="#E9E9E9">
		<p align="center"><span style="font-size: 9pt; font-weight: 700">
		<font face="Verdana" color="#224568">&nbsp;</font><font face="Verdana" color="#224568">Block 
	  wise Scheme wise population covered (as per PHED)</font></span></td>
	</tr>
	<tr>
	  <td bgcolor="#E9E9E9" height="26"><div align="center"><font face="Verdana" style="font-size: 9pt; font-weight: 700" color="#224568">Table 2 </font></div></td>
  </tr>
	<tr>
		<td bgcolor="#E9E9E9" height="56">
		<table border="1" width="757" cellspacing="0" cellpadding="0" height="61" bgcolor="#C5D8EB">
			<tr>
				<td width="40" align="center">
				<p align="center"><font face="Verdana" style="font-size: 8.5pt">
				S. No.</font></td>
				<td width="131" align="center">
				<font face="Verdana" style="font-size: 8.5pt">Name of the Block</font></td>
				<td width="130" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Type of the Scheme				</font></td>
				<td align="center" width="100">
				<font style="font-size: 8.5pt" face="Verdana">Numbers</font></td>
				<td align="center" width="97">
				<font style="font-size: 8.5pt" face="Verdana">Number of Villages 
				Covered</font></td>
				<td width="117" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Population covered 
				as of 2010</font></td>
				<td width="126" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Population per 
				Scheme</font></td>
			</tr>
		</table>		</td>
	</tr>
	<tr>
		<td>
		<table border="1" width="758" cellspacing="0" cellpadding="0" height="49" bordercolor="#C5D8EB" style="border: 1px solid #BBD1E8" bgcolor="#F9F9F9">
			<?php
			$numVillage=0;
			$numFormVill=0;
			$slNo = 1;
			$totalScheme = 0;
			$totalNumVill = 0;
			$totalPopulation = 0;
			$totalPopPerScheme = 0;									
			while($rowReport = mysql_fetch_array($queryReport)) {
			?>
			<tr>
				<td width="39" align="center" rowspan="5" valign="top"><font style="font-size: 8.5pt" face="Verdana"><?php echo $slNo; ?></font></td>
				<td width="132" align="center" rowspan="5" valign="top"><font style="font-size: 8.5pt" face="Verdana"><?php echo $rowReport['block_name']; ?></font></td>
				<td width="131" align="center">
				<font style="font-size: 8.5pt" face="Verdana">P &amp; T</font></td>
				<td align="center" width="99"><font style="font-size: 8.5pt" face="Verdana"><?php echo $numSchemePnT=getSchemeNoBlockWise($distId,'P&T',$rowReport['block_id'])+getSchemeNoBlockWise($distId,'TSS(P&T)',$rowReport['block_id']); ?></font></td>
				<td align="center" width="97"><font style="font-size: 8.5pt" face="Verdana"><?php echo $numVillagePnT=getSchemeNoBlockWise($distId,'P&T',$rowReport['block_id'])+getSchemeNoBlockWise($distId,'TSS(P&T)',$rowReport['block_id']); ?></font></td>
				<td width="118" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numPopulationPnT=getPopulationSchemeBlockWise($distId,'P&T',$rowReport['block_id'])+getPopulationSchemeBlockWise($distId,'TSS(P&T)',$rowReport['block_id']);
				if($numPopulationPnT=='')
				{
					echo $numPopulationPnT="0";
				}
				else
				{
				echo $numPopulationPnT ;} ?></font></td>
				<td align="center" width="126"><font style="font-size: 8.5pt" face="Verdana"><?php
				$a=getSchemeNoBlockWise($distId,'P&T',$rowReport['block_id'])+getSchemeNoBlockWise($distId,'TSS(P&T)',$rowReport['block_id']);
				if($a==0)
				{
				echo $numPopPerSchemePnT="0";
				}else{
				 echo $numPopPerSchemePnT=round((getPopulationSchemeBlockWise($distId,'P&T',$rowReport['block_id'])+getPopulationSchemeBlockWise($distId,'TSS(P&T)',$rowReport['block_id']))/$a);} ?></font></td>
			</tr>
			<tr>
				<td width="131" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Piped</font></td>
				<td align="center" width="99"><font style="font-size: 8.5pt" face="Verdana"><?php echo $numSchemePiped=getSchemeNoBlockWise($distId,'piped',$rowReport['block_id']); ?></font></td>
				<td align="center" width="97"><font style="font-size: 8.5pt" face="Verdana"><?php echo $numVillagePiped=getSchemeNoBlockWise($distId,'piped',$rowReport['block_id']); ?></font></td>
				<td align="center"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numPopulationPiped=getPopulationSchemeBlockWise($distId,'piped',$rowReport['block_id']);
				if($numPopulationPiped=='')
				{
					echo $numPopulationPiped="0";
				}
				else
				{
				
				echo $numPopulationPiped ; }?></font></td>
				<td align="center" width="126"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$a=getSchemeNoBlockWise($distId,'piped',$rowReport['block_id']);
				if($a==0)
				{
				echo $numPopPerSchemePiped="0";
				}else{
				echo $numPopPerSchemePiped=round(getPopulationSchemeBlockWise($distId,'piped',$rowReport['block_id'])/$a);} ?></font></td>
			</tr>
			<tr>
				<td width="131" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Sanitary Diggs</font></td>
				<td align="center" width="99"><font style="font-size: 8.5pt" face="Verdana"><?php echo $numSchemeSanDig=getSchemeNoBlockWise($distId,'Sanitary Diggs',$rowReport['block_id']); ?></font></td>
				<td align="center" width="97"><font style="font-size: 8.5pt" face="Verdana"><?php echo $numVillageSanDig=getSchemeNoBlockWise($distId,'Sanitary Diggs',$rowReport['block_id']); ?></font></td>
				<td align="center"><font style="font-size: 8.5pt" face="Verdana"><?php 
				
				$numPopulationSanDig=getPopulationSchemeBlockWise($distId,'Sanitary Diggs',$rowReport['block_id']);
				if($numPopulationSanDig=='')
				{
					echo $numPopulationSanDig="0";
				}
				else
				{
				echo $numPopulationSanDig ;} ?></font></td>
				<td align="center" width="126"><font style="font-size: 8.5pt" face="Verdana"><?php 
				
				$a=getSchemeNoBlockWise($distId,'Sanitary Diggs',$rowReport['block_id']);
				if($a==0)
				{
				echo $numPopPerSchemeSanDig="0";
				}else{
				echo $numPopPerSchemeSanDig=round(getPopulationSchemeBlockWise($distId,'Sanitary Diggs',$rowReport['block_id'])/$a);} ?></font></td>
			</tr>
			<tr>
				<td width="131" align="center">
				<font style="font-size: 8.5pt" face="Verdana">HP</font></td>
				<td align="center" width="99"><font style="font-size: 8.5pt" face="Verdana"><?php echo $numSchemeHp=getSchemeNoBlockWise($distId,'HP',$rowReport['block_id']); ?></font></td>
				<td align="center" width="97"><font style="font-size: 8.5pt" face="Verdana"><?php echo $numVillageHp=getSchemeNoBlockWise($distId,'HP',$rowReport['block_id']); ?></font></td>
				<td align="center"><font style="font-size: 8.5pt" face="Verdana"><?php 
				
				$numPopulationHp=getPopulationSchemeBlockWise($distId,'HP',$rowReport['block_id']);
				if($numPopulationHp=='')
				{
					echo $numPopulationHp="0";
				}
				else
				{
				echo $numPopulationHp ;} ?></font></td>
				<td align="center" width="126"><font style="font-size: 8.5pt" face="Verdana"><?php
				$a=getSchemeNoBlockWise($distId,'HP',$rowReport['block_id']);
				if($a==0)
				{
				echo $numPopPerSchemeHp="0";
				}else{
				 echo $numPopPerSchemeHp=round(getPopulationSchemeBlockWise($distId,'HP',$rowReport['block_id'])/$a); }?></font></td>
			</tr>
			<tr>
			<?php 
			$totalScheme = $numSchemeHp + $numSchemePiped + $numSchemePnT + $numSchemeSanDig ;//+$numSchemeHp;
			$totalNumVill = $numVillageHp + $numVillagePiped + $numVillagePnT + $numVillageSanDig ;//+$numSchemeHp;
			$totalPopulation = $numPopulationHp + $numPopulationPiped + $numPopulationPnT + $numPopulationSanDig ;// +$numSchemeHp;
			$totalPopPerScheme = $numPopPerSchemeHp + $numPopPerSchemePiped + $numPopPerSchemePnT;// +$numSchemeHp;
			$grandTotalScheme+=$totalScheme;
			$granTotalNumVill+=$totalNumVill;
			$grandTotalPop+=$totalPopulation;
			$granTotalPopPerScheme+=$totalPopPerScheme;
			?>
				<td width="131" align="center" bgcolor="#E9E9E9">
				<font style="font-size: 8.5pt" face="Verdana">Total</font></td>
				<td align="center" width="99" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $totalScheme; ?></font></td>
				<td align="center" width="97" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $totalNumVill; ?></font></td>
				<td align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $totalPopulation; ?></font></td>
				<td align="center" width="126" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php //echo $totalPopPerScheme; 
				if($totalScheme==0)
				{
					echo $numPopPerSchemeTotal="0";
				}
				else
				{
					echo $numPopPerSchemeTotal=round($totalPopulation/$totalScheme);
				}
				
				?></font></td>
			</tr>
			<?php 
			$slNo++;
			} ?>
			<tr>
			<td align="center" bgcolor="#E9E9E9" colspan="3">
				<font style="font-size: 8.5pt" face="Verdana">Grand Total</font></td>
				<td align="center" width="99" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $grandTotalScheme;?></font></td>
				<td align="center" width="97" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $granTotalNumVill;?></font></td>
				<td align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php echo $grandTotalPop;?></font></td>
				<td align="center" width="126" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><?php //echo $granTotalPopPerScheme;
				if($grandTotalScheme==0)
				{
					echo $numPopPerSchemeGrand="0";
				}
				else
				{
					echo $numPopPerSchemeGrand=round($grandTotalPop/$grandTotalScheme);
				}
				
				?></font></td>
			</tr>
		</table>		</td>
	</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

</body>

</html>
